home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_glimpse.idb / usr / freeware / catman / u_man / cat1 / agrep.Z / agrep
Text File  |  1997-09-09  |  19KB  |  463 lines

  1.  
  2.  
  3.  
  4.      AAAAGGGGRRRREEEEPPPP((((llll))))           UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((JJJJaaaannnn 11117777,,,, 1111999999992222))))          AAAAGGGGRRRREEEEPPPP((((llll))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       agrep    - search a file    for a string or    regular    expression,
  10.       with approximate matching capabilities
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.       aaaaggggrrrreeeepppp    [ ----####ccccddddeeeehhhhiiiikkkkllllnnnnppppssssttttvvvvwwwwxxxxBBBBDDDDGGGGIIIISSSS    ] _p_a_t_t_e_r_n [ -f _p_a_t_t_e_r_n_f_i_l_e ] [
  14.       _f_i_l_e_n_a_m_e... ]
  15.  
  16.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  17.       aaaaggggrrrreeeepppp    searches the input _f_i_l_e_n_a_m_e_s (standard input is    the
  18.       default, but see a warning under LIMITATIONS)    for records
  19.       containing strings which either _e_x_a_c_t_l_y or _a_p_p_r_o_x_i_m_a_t_e_l_y
  20.       match    a pattern. A record is by default a line, but it can
  21.       be defined differently using the -d option (see below).
  22.       Normally, each record    found is copied    to the standard
  23.       output.  Approximate matching    allows finding records that
  24.       contain the pattern with several errors including
  25.       substitutions, insertions, and deletions.  For example,
  26.       Massechusets matches Massachusetts with two errors (one
  27.       substitution and one insertion).  Running aaaaggggrrrreeeepppp -2
  28.       Massechusets foo outputs all lines in    foo containing any
  29.       string with at most 2    errors from Massechusets.
  30.  
  31.       aaaaggggrrrreeeepppp    supports many kinds of queries including arbitrary
  32.       wild cards, sets of patterns,    and in general,    regular
  33.       expressions.    See PATTERNS below.  It    supports most of the
  34.       options supported by the ggggrrrreeeepppp    family plus several more (but
  35.       it is    not 100% compatible with grep).     For more information
  36.       on the algorithms used by agrep see Wu and Manber, "Fast
  37.       Text Searching With Errors," Technical report    #91-11,
  38.       Department of    Computer Science, University of    Arizona, June
  39.       1991 (available by anonymous ftp from    cs.arizona.edu in
  40.       agrep/agrep.ps.1), and Wu and    Manber,    "Agrep -- A Fast
  41.       Approximate Pattern Searching    Tool", To appear in USENIX
  42.       Conference 1992 January (available by    anonymous ftp from
  43.       cs.arizona.edu in agrep/agrep.ps.2).
  44.  
  45.       As with the rest of the ggggrrrreeeepppp family, the characters `$$$$',
  46.       `^'''',,,, `****', `[[[[',,,, `]]]]',,,, `^^^^', `||||',    `((((', `))))', `!!!!', and `\\\\' can
  47.       cause    unexpected results when    included in the    _p_a_t_t_e_r_n, as
  48.       these    characters are also meaningful to the shell.  To avoid
  49.       these    problems, one should always enclose the    entire pattern
  50.       argument in single quotes, i.e., 'pattern'.  Do not use
  51.       double quotes    (").
  52.  
  53.       When aaaaggggrrrreeeepppp is    applied    to more    than one input file, the name
  54.       of the file is displayed preceding each line which matches
  55.       the pattern.    The filename is    not displayed when processing
  56.       a single file, so if you actually want the filename to
  57.       appear, use ////ddddeeeevvvv////nnnnuuuullllllll    as a second file in the    list.
  58.  
  59.      OOOOPPPPTTTTIIIIOOOONNNNSSSS
  60.  
  61.  
  62.  
  63.      PPPPaaaaggggeeee 1111                         ((((pppprrrriiiinnnntttteeeedddd 11111111////3333////99995555))))
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      AAAAGGGGRRRREEEEPPPP((((llll))))           UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((JJJJaaaannnn 11117777,,,, 1111999999992222))))          AAAAGGGGRRRREEEEPPPP((((llll))))
  71.  
  72.  
  73.  
  74.       ----#   # is a non-negative integer (at most 8) specifying the
  75.            maximum number of errors    permitted in finding the
  76.            approximate matches (defaults to    zero).    Generally,
  77.            each insertion, deletion, or substitution counts    as one
  78.            error.  It is possible to adjust    the relative cost of
  79.            insertions, deletions and substitutions (see -I -D and
  80.            -S options).
  81.  
  82.       ----cccc   Display only the    count of matching records.
  83.  
  84.       ----dddd ''''_d_e_l_i_m''''
  85.            Define _d_e_l_i_m to be the separator    between    two records.
  86.            The default value is '$', namely    a record is by default
  87.            a line.    _d_e_l_i_m can be a string of size at most 8    (with
  88.            possible    use of ^ and $), but not a regular expression.
  89.            Text between two    _d_e_l_i_m's, before    the first _d_e_l_i_m, and
  90.            after the last _d_e_l_i_m is considered as one record.  For
  91.            example,    -d '$$'    defines    paragraphs as records and -d
  92.            '^From '    defines    mail messages as records.  aaaaggggrrrreeeepppp
  93.            matches each record separately.    This option does not
  94.            currently work with regular expressions.
  95.  
  96.       ----eeee _p_a_t_t_e_r_n
  97.            Same as a simple    _p_a_t_t_e_r_n    argument, but useful when the
  98.            _p_a_t_t_e_r_n begins with a `----'.
  99.  
  100.       ----ffff _p_a_t_t_e_r_n_f_i_l_e
  101.            _p_a_t_t_e_r_n_f_i_l_e contains a set of (simple) patterns.     The
  102.            output is all lines that    match at least one of the
  103.            patterns    in _p_a_t_t_e_r_n_f_i_l_e.    Currently, the -f option works
  104.            only for    exact match and    for simple patterns (any meta
  105.            symbol is interpreted as    a regular character); it is
  106.            compatible only with -c,    -h, -i,    -l, -s,    -v, -w,    and -x
  107.            options.     see LIMITATIONS for size bounds.
  108.  
  109.       ----hhhh   Do not display filenames.
  110.  
  111.       ----iiii   Case-insensitive    search - e.g., "A" and "a" are
  112.            considered equivalent.
  113.  
  114.       ----kkkk   No symbol in the    pattern    is treated as a    meta
  115.            character. For example, agrep -k    'a(b|c)*d' foo will
  116.            find the    occurrences of a(b|c)*d    in foo whereas agrep
  117.            'a(b|c)*d' foo will find    substrings in foo that match
  118.            the regular expression 'a(b|c)*d'.
  119.  
  120.       ----llll   List only the files that    contain    a match.  This option
  121.            is useful for looking for files containing a certain
  122.            pattern.     For example, "    agrep -l 'wonderful'  *    " will
  123.            list the    names of those files in    current    directory that
  124.            contain the word    'wonderful'.
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                         (printed 11/3/95)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      AAAAGGGGRRRREEEEPPPP((((llll))))           UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((JJJJaaaannnn 11117777,,,, 1111999999992222))))          AAAAGGGGRRRREEEEPPPP((((llll))))
  137.  
  138.  
  139.  
  140.       ----nnnn   Each line that is printed is prefixed by    its record
  141.            number in the file.
  142.  
  143.       ----pppp   Find records in the text    that contain a supersequence
  144.            of the pattern.    For example,
  145.         aaaaggggrrrreeeepppp ----pppp DDDDCCCCSSSS ffffoooooooo wwwwiiiillllllll mmmmaaaattttcccchhhh """"DDDDeeeeppppaaaarrrrttttmmmmeeeennnntttt    ooooffff CCCCoooommmmppppuuuutttteeeerrrr
  146.            SSSScccciiiieeeennnncccceeee....""""
  147.  
  148.       ----ssss   Work silently, that is, display nothing except error
  149.            messages.  This is useful for checking the error
  150.            status.
  151.  
  152.       ----tttt   Output the record starting from the end of _d_e_l_i_m    to
  153.            (and including) the next    _d_e_l_i_m. This is useful for
  154.            cases where _d_e_l_i_m should    come at    the end    of the record.
  155.  
  156.       ----vvvv   Inverse mode - display only those records that _d_o _n_o_t
  157.            contain the pattern.
  158.  
  159.       ----wwww   Search for the pattern as a word    - i.e.,    surrounded by
  160.            non-alphanumeric    characters.  The non-alphanumeric mmmmuuuusssstttt
  161.            surround    the match;  they cannot    be counted as errors.
  162.            For example, aaaaggggrrrreeeepppp -w -1    car will match cars, but not
  163.            characters.
  164.  
  165.       ----xxxx   The pattern must    match the whole    line.
  166.  
  167.       ----yyyy   Used with -B option. When -y is on, agrep will always
  168.            output the best matches without giving a    prompt.
  169.  
  170.       ----BBBB   Best match mode.     When -B is specified and no exact
  171.            matches are found, agrep    will continue to search    until
  172.            the closest matches (i.e., the ones with    minimum    number
  173.            of errors) are found, at    which point the    following
  174.            message will be shown:  "the best match contains    x
  175.            errors, there are y matches, output them? (y/n)"    The
  176.            best match mode is not supported    for standard input,
  177.            e.g., pipeline input.  When the -#, -c, or -l options
  178.            are specified, the -B option is ignored.     In general,
  179.            -B may be slower    than -#, but not by very much.
  180.  
  181.       ----DDDD_k  Set the cost of a deletion to _k (_k is a positive
  182.            integer).  This option does not currently work with
  183.            regular expressions.
  184.  
  185.       ----GGGG   Output the files    that contain a match.
  186.  
  187.       ----IIII_k  Set the cost of an insertion to _k (_k is a positive
  188.            integer).  This option does not currently work with
  189.            regular expressions.
  190.  
  191.       ----SSSS_k  Set the cost of a substitution to _k (_k is a positive
  192.  
  193.  
  194.  
  195.      Page 3                         (printed 11/3/95)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      AAAAGGGGRRRREEEEPPPP((((llll))))           UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((JJJJaaaannnn 11117777,,,, 1111999999992222))))          AAAAGGGGRRRREEEEPPPP((((llll))))
  203.  
  204.  
  205.  
  206.            integer).  This option does not currently work with
  207.            regular expressions.
  208.  
  209.      PPPPAAAATTTTTTTTEEEERRRRNNNNSSSS
  210.       _a_g_r_e_p    supports a large variety of patterns, including    simple
  211.       strings, strings with    classes    of characters, sets of
  212.       strings, wild    cards, and regular expressions.
  213.  
  214.       SSSSttttrrrriiiinnnnggggssss
  215.            any sequence of characters, including the special
  216.            symbols `^' for beginning of line and `$' for end of
  217.            line.  The special characters listed above ( `$$$$', `^'''',,,,
  218.            `****', `[[[[',,,, `^^^^', `||||', `((((',    `))))', `!!!!', and `\\\\' ) should be
  219.            preceded    by `\' if they are to be matched as regular
  220.            characters.  For    example, \^abc\\ corresponds to    the
  221.            string ^abc\, whereas ^abc corresponds to the string
  222.            abc at the beginning of a line.
  223.  
  224.       CCCCllllaaaasssssssseeeessss ooooffff cccchhhhaaaarrrraaaacccctttteeeerrrrssss
  225.            a list of characters inside [] (in order) corresponds
  226.            to any character    from the list.    For example, [a-ho-z]
  227.            is any character    between    a and h    or between o and z.
  228.            The symbol `^' inside []    complements the    list.  For
  229.            example,    [^i-n] denote any character in the character
  230.            set except character 'i'    to 'n'.     The symbol `^'    thus
  231.            has two meanings, but this is consistent    with egrep.
  232.            The symbol `.' (don't care) stands for any symbol
  233.            (except for the newline symbol).
  234.  
  235.       BBBBoooooooolllleeeeaaaannnn ooooppppeeeerrrraaaattttiiiioooonnnnssss
  236.            aaaaggggrrrreeeepppp supports an `and' operation `;' and an `or'
  237.            operation `,', but not a    combination of both.  For
  238.            example,    'fast;network' searches    for all    records
  239.            containing both words.
  240.  
  241.       WWWWiiiilllldddd ccccaaaarrrrddddssss
  242.            The symbol '#' is used to denote    a wild card.  #
  243.            matches zero or any number of arbitrary characters.
  244.            For example, ex#e matches example.  The symbol #    is
  245.            equivalent to .*    in egrep.  In fact, .* will work too,
  246.            because it is a valid regular expression    (see below),
  247.            but unless this is part of an actual regular
  248.            expression, # will work faster.
  249.  
  250.       CCCCoooommmmbbbbiiiinnnnaaaattttiiiioooonnnn ooooffff eeeexxxxaaaacccctttt aaaannnndddd aaaapppppppprrrrooooxxxxiiiimmmmaaaatttteeee mmmmaaaattttcccchhhhiiiinnnngggg
  251.            any pattern inside angle    brackets <> must match the
  252.            text exactly even if the    match is with errors.  For
  253.            example,    <mathemat>ics matches mathematical with    one
  254.            error (replacing    the last s with    an a), but
  255.            mathe<matics> does not match mathematical no matter how
  256.            many errors we allow.
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                         (printed 11/3/95)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      AAAAGGGGRRRREEEEPPPP((((llll))))           UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((JJJJaaaannnn 11117777,,,, 1111999999992222))))          AAAAGGGGRRRREEEEPPPP((((llll))))
  269.  
  270.  
  271.  
  272.       RRRReeeegggguuuullllaaaarrrr eeeexxxxpppprrrreeeessssssssiiiioooonnnnssss
  273.            The syntax of regular expressions in aaaaggggrrrreeeepppp is in
  274.            general the same    as that    for eeeeggggrrrreeeepppp.  The    union
  275.            operation `|', Kleene closure `*', and parentheses ()
  276.            are all supported.  Currently '+' is not    supported.
  277.            Regular expressions are currently limited to
  278.            approximately 30    characters (generally excluding    meta
  279.            characters).  Some options (-d, -w, -f, -t, -x, -D, -I,
  280.            -S) do not currently work with regular expressions.
  281.            The maximal number of errors for    regular    expressions
  282.            that use    '*' or '|' is 4.
  283.  
  284.      EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  285.       agrep    -2 -c ABCDEFG foo
  286.            gives the number    of lines in file foo that contain
  287.            ABCDEFG within two errors.
  288.  
  289.       agrep    -1 -D2 -S2 'ABCD#YZ' foo
  290.            outputs the lines containing ABCD followed, within
  291.            arbitrary distance, by YZ, with up to one additional
  292.            insertion (-D2 and -S2 make deletions and substitutions
  293.            too "expensive").
  294.  
  295.       agrep    -5 -p abcdefghij /usr/dict/words
  296.            outputs the list    of all words containing    at least 5 of
  297.            the first 10 letters of the alphabet _i_n _o_r_d_e_r.  (Try
  298.            it:  any    list starting with academia and    ending with
  299.            sacrilegious must mean something!)
  300.  
  301.       agrep    -1 'abc[0-9](de|fg)*[x-z]' foo
  302.            outputs the lines containing, within up to one error,
  303.            the string that starts with abc followed    by one digit,
  304.            followed    by zero    or more    repetitions of either de or
  305.            fg, followed by either x, y, or z.
  306.  
  307.       agrep    -d '^From ' 'breakdown;internet' mbox
  308.            outputs all mail    messages (the pattern '^From '
  309.            separates mail messages in a mail file) that contain
  310.            keywords    'breakdown' and    'internet'.
  311.  
  312.       agrep    -d '$$'    -1 '<word1> <word2>' foo
  313.            finds all paragraphs that contain word1 followed    by
  314.            word2 with one error in place of    the blank. In
  315.            particular, if word1 is the last    word in    a line and
  316.            word2 is    the first word in the next line, then the
  317.            space will be substituted by a newline symbol and it
  318.            will match.  Thus, this is a way    to overcome separation
  319.            by a newline.  Note that    -d '$$'    (or another delim
  320.            which spans more    than one line) is necessary, because
  321.            otherwise agrep searches    only one line at a time.
  322.  
  323.       agrep    '^agrep' <this manual>
  324.  
  325.  
  326.  
  327.      Page 5                         (printed 11/3/95)
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      AAAAGGGGRRRREEEEPPPP((((llll))))           UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((JJJJaaaannnn 11117777,,,, 1111999999992222))))          AAAAGGGGRRRREEEEPPPP((((llll))))
  335.  
  336.  
  337.  
  338.            outputs all the examples    of the use of agrep in this
  339.            man pages.
  340.  
  341.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  342.       eeeedddd(1), eeeexxxx(1),    ggggrrrreeeepppp(1V), sssshhhh(1), ccccsssshhhh(1).
  343.  
  344.      BBBBUUUUGGGGSSSS////LLLLIIIIMMMMIIIITTTTAAAATTTTIIIIOOOONNNNSSSS
  345.       Any bug reports or comments will be appreciated! Please mail
  346.       them to sw@cs.arizona.edu or udi@cs.arizona.edu
  347.  
  348.       Regular expressions do not support the '+' operator (match 1
  349.       or more instances of the preceding token).  These can    be
  350.       searched for by using    this syntax in the pattern:
  351.  
  352.            '_p_a_t_t_e_r_n((((_p_a_t_t_e_r_n))))****'
  353.  
  354.       (search for strings containing one instance of the pattern,
  355.       followed by 0    or more    instances of the pattern).
  356.  
  357.       The following    can cause an infinite loop:  aaaaggggrrrreeeepppp pattern * >
  358.       output_file.    If the number of matches is high, they may be
  359.       deposited in output_file before it is    completely read
  360.       leading to more matches of the pattern within    output_file
  361.       (the matches are against the whole directory).  It's not
  362.       clear    whether    this is    a "bug"    (grep will do the same), but
  363.       be warned.
  364.  
  365.       The maximum size of the _p_a_t_t_e_r_n_f_i_l_e is limited to be 250Kb,
  366.       and the maximum number of patterns is    limited    to be 30,000.
  367.  
  368.       Standard input is the    default    if no input file is given.
  369.       However, if standard input is    keyed in directly (as opposed
  370.       to through a pipe, for example) agrep    may not    work for some
  371.       non-simple patterns.
  372.  
  373.       There    is no size limit for simple patterns.  More
  374.       complicated patterns are currently limited to    approximately
  375.       30 characters.  Lines    are limited to 1024 characters.
  376.       Records are limited to 48K, and may be truncated if they are
  377.       larger than that.  The limit of record length    can be changed
  378.       by modifying the parameter Max_record    in agrep.h.
  379.  
  380.      DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  381.       Exit status is 0 if any matches are found, 1 if none,    2 for
  382.       syntax errors    or inaccessible    files.
  383.  
  384.      AAAAUUUUTTTTHHHHOOOORRRRSSSS
  385.       Sun Wu and Udi Manber, Department of Computer    Science,
  386.       University of    Arizona, Tucson, AZ 85721.
  387.       {sw|udi}@cs.arizona.edu.
  388.  
  389.  
  390.  
  391.  
  392.  
  393.      Page 6                         (printed 11/3/95)
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.      AAAAGGGGRRRREEEEPPPP((((llll))))           UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((JJJJaaaannnn 11117777,,,, 1111999999992222))))          AAAAGGGGRRRREEEEPPPP((((llll))))
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.      Page 7                         (printed 11/3/95)
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.